<template>
  <div class="screen-layout-with-menu">
    <!-- 顶部标题栏（单独一行） -->
    <div class="header-bar">
      <div class="header-title">供应链基础数据可视化产品</div>
    </div>

    <!-- 筛选栏（单独一行） -->
    <div class="filter-bar">
      <select v-model="filters.supplierType" class="filter-select">
        <option value="所有">供应商类型</option>
        <option value="所有">所有</option>
        <option value="类型A">类型A</option>
        <option value="类型B">类型B</option>
        <option value="类型C">类型C</option>
      </select>
      <select v-model="filters.supplierName" class="filter-select">
        <option value="所有">供应商名称</option>
        <option value="所有">所有</option>
        <option value="供应商1">供应商1</option>
        <option value="供应商2">供应商2</option>
        <option value="供应商3">供应商3</option>
      </select>
      <select v-model="filters.customerType" class="filter-select">
        <option value="所有">客户类型</option>
        <option value="所有">所有</option>
        <option value="Hospital">Hospital</option>
        <option value="Pharmacy">Pharmacy</option>
        <option value="Clinic">Clinic</option>
      </select>
      <select v-model="filters.customerName" class="filter-select">
        <option value="Customer_10">客户名称</option>
        <option value="Customer_10">Customer_10</option>
        <option value="Customer_1">Customer_1</option>
        <option value="Customer_2">Customer_2</option>
        <option value="所有">所有</option>
      </select>
      <select v-model="filters.productCategory" class="filter-select">
        <option value="所有">产品类别</option>
        <option value="所有">所有</option>
        <option value="Antibiotics">Antibiotics</option>
        <option value="Antiviral">Antiviral</option>
        <option value="Painkillers">Painkillers</option>
      </select>
      <select v-model="filters.productName" class="filter-select">
        <option value="所有">产品名称</option>
        <option value="所有">所有</option>
        <option value="Product_1">Product_1</option>
        <option value="Product_2">Product_2</option>
        <option value="Product_3">Product_3</option>
      </select>
      <select v-model="filters.yearMonth" class="filter-select">
        <option value="所有">年、月份</option>
        <option value="所有">所有</option>
        <option value="2024">2024</option>
        <option value="2023">2023</option>
        <option value="2022">2022</option>
      </select>
    </div>

    <!-- 下方内容区：左侧菜单栏 + 右侧图表 -->
    <div class="bottom-section">
      <!-- 左侧导航栏 -->
      <div class="sidebar">
        <div class="sidebar-title">
          <span>导航栏</span>
        </div>
        <div class="nav-menu">
          <div 
            v-for="item in navItems" 
            :key="item.path"
            class="nav-item"
            :class="{ active: currentPath === item.path }"
            @click="navigate(item.path)"
          >
            <span>{{ item.name }}</span>
          </div>
        </div>
      </div>

      <!-- 右侧内容区 -->
      <div class="screen-content">
        <slot />
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted, onUnmounted, computed } from 'vue'
import { useRoute, useRouter } from 'vue-router'

const props = defineProps({
  title: {
    type: String,
    default: '供应链基础数据可视化产品'
  }
})

const route = useRoute()
const router = useRouter()
const currentPath = computed(() => route.path)
const currentTime = ref('')

const filters = ref({
  supplierType: '所有',
  supplierName: '所有',
  customerType: '所有',
  customerName: 'Customer_10',
  productCategory: '所有',
  productName: '所有',
  yearMonth: '所有'
})

// 菜单项
const navItems = [
  { name: 'Dashboard', path: '/dashboard' },
  { name: '绩效分析', path: '/performance' },
  { name: '采购分析', path: '/procurement' },
  { name: '库存管理', path: '/inventory' },
  { name: '运输配送', path: '/logistics' },
  { name: '订单分析', path: '/orders' },
  { name: '成本分析', path: '/cost' },
  { name: '监控预警', path: '/monitoring' }
]

const navigate = (path) => {
  router.push(path)
}

const updateTime = () => {
  currentTime.value = new Date().toLocaleString('zh-CN', {
    year: 'numeric',
    month: '2-digit',
    day: '2-digit',
    hour: '2-digit',
    minute: '2-digit',
    second: '2-digit'
  })
}

let timer = null
onMounted(() => {
  updateTime()
  timer = setInterval(updateTime, 1000)
})

onUnmounted(() => {
  if (timer) {
    clearInterval(timer)
  }
})
</script>

<style scoped>
.screen-layout-with-menu {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  position: relative;
  background: linear-gradient(135deg, #0a0e27 0%, #1a1f3a 100%);
  color: #fff;
}

/* 顶部标题栏（单独一行） */
.header-bar {
  width: 100%;
  background: linear-gradient(90deg, rgba(24, 144, 255, 0.1) 0%, rgba(24, 144, 255, 0.05) 100%);
  border-bottom: 2px solid rgba(24, 144, 255, 0.3);
  padding: 15px 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  min-height: 50px;
}

.header-bar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    linear-gradient(90deg, transparent 0%, rgba(24, 144, 255, 0.1) 50%, transparent 100%);
  animation: headerShine 3s infinite;
}

@keyframes headerShine {
  0%, 100% { transform: translateX(-100%); }
  50% { transform: translateX(100%); }
}

.header-title {
  font-size: 24px;
  font-weight: bold;
  background: linear-gradient(90deg, #1890ff, #36cfc9);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 20px rgba(24, 144, 255, 0.5);
  letter-spacing: 2px;
  white-space: nowrap;
  text-align: center;
}

/* 筛选栏（单独一行） */
.filter-bar {
  width: 100%;
  background: rgba(15, 25, 45, 0.3);
  border-bottom: 1px solid rgba(24, 144, 255, 0.2);
  padding: 8px 40px;
  display: flex;
  gap: 15px;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.filter-select {
  flex: 1;
  min-width: 140px;
  padding: 8px 12px;
  background: rgba(15, 25, 45, 0.6);
  border: 1px solid rgba(24, 144, 255, 0.3);
  border-radius: 6px;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s;
}

.filter-select:hover {
  border-color: rgba(24, 144, 255, 0.6);
  background: rgba(15, 25, 45, 0.8);
}

.filter-select:focus {
  outline: none;
  border-color: #1890ff;
  box-shadow: 0 0 8px rgba(24, 144, 255, 0.3);
}

.filter-select option {
  background: #1a1f3a;
  color: #fff;
  padding: 8px;
}

/* 下方内容区 */
.bottom-section {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}


.sidebar {
  width: 200px;
  background: rgba(15, 25, 45, 0.8);
  border-right: 1px solid rgba(24, 144, 255, 0.3);
  padding: 20px 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.sidebar-title {
  padding: 0 20px 20px;
  font-size: 16px;
  color: #999;
  border-bottom: 1px solid rgba(24, 144, 255, 0.2);
  margin-bottom: 20px;
  margin-top: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.nav-menu::-webkit-scrollbar {
  width: 6px;
}

.nav-menu::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
}

.nav-menu::-webkit-scrollbar-thumb {
  background: rgba(24, 144, 255, 0.5);
  border-radius: 3px;
}

.nav-menu::-webkit-scrollbar-thumb:hover {
  background: rgba(24, 144, 255, 0.8);
}

.nav-item {
  padding: 15px 20px;
  cursor: pointer;
  transition: all 0.3s;
  color: #999;
  border-left: 3px solid transparent;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.nav-item:hover {
  background: rgba(24, 144, 255, 0.1);
  color: #fff;
}

.nav-item.active {
  background: rgba(24, 144, 255, 0.2);
  color: #36cfc9;
  border-left-color: #36cfc9;
}

.screen-content {
  flex: 1;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  background: linear-gradient(135deg, #0a0e27 0%, #1a1f3a 100%);
  min-height: 0;
}

.screen-content::-webkit-scrollbar {
  width: 8px;
}

.screen-content::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.screen-content::-webkit-scrollbar-thumb {
  background: rgba(24, 144, 255, 0.5);
  border-radius: 4px;
}

.screen-content::-webkit-scrollbar-thumb:hover {
  background: rgba(24, 144, 255, 0.8);
}
</style>